table.insert(itemActions,
	function(item, action)
		-- MAGIC jewels
		-- see: dir .. "readme.txt" for information regarding these variables
		local priority = 5
		local identify = true -- use false if you want to keep junk jewels
		local dump = false

		if not (item.quality == ItemQuality.Magic and item.baseItem.code == "jew") then
			return false
		elseif action == aPICK and  (not item.flags.Identified or isGoodMagicJewel(item)) then
			return priority
		elseif action == aIDENT then
			return identify
		elseif action == aSELL and item.flags.Identified and not isGoodMagicJewel(item) then
			return true
		elseif action == aDUMP and item.flags.Identified and not isGoodMagicJewel(item) then
			return dump
		end

		return false
	end
)

function isGoodMagicJewel(item)
	-- note: ed, maxdam, mindam, mp, str, dex, eng, and hp are given numeric values
	-- so you can add customize  the mods you want in the return
	-- feel free to change the lower prefix/suffix bounds
	-- do NOT try to compare or assign boolean variables with numbers
	-- i.e. IAS. Either it has it or it doesn't. So it's true/false not 0, 1 or 15.
	local prefix = false
	local ed, maxdam, mindam, mp = 0, 0, 0, 0
	local suffix = false
	local str, dex, eng, hp, ias, fhr, req = 0, 0, 0, 0, false, false, false
	local affix = false
	
	if hasRes(item, 8, 4) or hasRes(item, 20, 1) then -- 10+allres or 20+singleres->prefix
		prefix = true
	end

	if hasRes(item, 10, 4) then -- 12allres->affix
		affix = true
	end

	for i = 0, item.mods:size() - 1 do
		if item.mods[i].Stat.Type == StatType.MaxDamagePercent then
			 if item.mods[i].Value >= 25 then -- 30+edam->prefix
				prefix = true
			end
			ed = item.mods[i].Value
		elseif item.mods[i].Stat.Type == StatType.MaxDamage then
			 if item.mods[i].Value >= 10 then -- 12+ Max Dmg->suffix
				suffix = true
			end
			maxdam = item.mods[i].Value
		elseif item.mods[i].Stat.Type == StatType.MinDamage then
			 if item.mods[i].Value >= 10 then -- 12+ Min Dmg->suffix
				suffix = true
			end
			mindam = item.mods[i].Value
		elseif item.mods[i].Stat.Type == StatType.MaxMana then
			 if item.mods[i].Value >= 10 then -- 15+mp->prefix
				prefix = true
			end
			mp = item.mods[i].Value
		elseif item.mods[i].Stat.Type == StatType.Strength then
			 if item.mods[i].Value >= 5 then -- 7+str->suffix
				suffix = true
			end
			str = item.mods[i].Value
		elseif item.mods[i].Stat.Type == StatType.Dexterity then
			 if item.mods[i].Value >= 5 then -- 7+dex->suffix
				suffix = true
			end
			dex = item.mods[i].Value
		elseif item.mods[i].Stat.Type == StatType.Energy then
			 if item.mods[i].Value >= 5 then -- 7+eng->suffix
				suffix = true
			end
			eng = item.mods[i].Value
		elseif item.mods[i].Stat.Type == StatType.MaxLife then
			 if item.mods[i].Value >= 15 then -- 15+hp->suffix
				suffix = true
			end
			hp = item.mods[i].Value
		elseif item.mods[i].Stat.Type == StatType.FasterAttackRate then
			ias = true -- ias->suffix
			suffix = true
		elseif item.mods[i].Stat.Type == StatType.FasterHitRecovery then
			fhr = true -- fhr->suffix
			suffix = true
		elseif item.mods[i].Stat.Type == StatType.LowerRequirementsPercent then
			req = true -- req->suffix
			suffix = true
		end
	end

	return (
			(edam >= 30) -- example of custom jewel
			or (prefix and suffix)
			or (ias or req) and (prefix or suffix)
			or affix
			)
end